package com.xbongbong.paas.config.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * 工作流触发方式
 * @author 吴峰
 * @date 2021/05/10 15:09
 */
@Getter
public enum WorkflowTriggerMethodEnum {

    /**
     *
     */
    NONE(0, "非触发节点"),
    FORM(1, "表单事件触发"),
    TIME(2, "时间触发"),
    TIME_FIELD(3, "时间字段触发"),
    WEB_HOOK(4, "webhook触发"),
    USER(5, "员工事件触发"),
    CUSTOM_TRIGGER_METHOD(6, "自定义触发方式"),

    ;

    private Integer type;

    private String memo;

    WorkflowTriggerMethodEnum(Integer type, String memo) {
        this.type = type;
        this.memo = memo;
    }

    public static String getMemoByType(Integer type) {
        for (WorkflowTriggerMethodEnum workflowTriggerMethodEnum: values()) {
            if (Objects.equals(workflowTriggerMethodEnum.getType(), type)) {
                return workflowTriggerMethodEnum.getMemo();
            }
        }
        return null;
    }

    public static WorkflowTriggerMethodEnum getByType(Integer type) {
        for (WorkflowTriggerMethodEnum value : values()) {
            if (Objects.equals(value.getType(), type)) {
                return value;
            }
        }
        return null;
    }
}
